<?php
class App_Module_Admin_Component_Service_Ctrl_Http extends Mozg_Controller_Instance
{
    public function DeleteHTMLCache()
    {
        $this->DeleteCache(_CACHE_PATH_STYLE, 'html');
        return true;
    }
	
    public function DeleteCSSCache()
    {
        $this->DeleteCache(_CACHE_PATH_STYLE, 'css');
        return true;
    }
    
    public function DeleteJSCache()
    {
        $this->DeleteCache(_CACHE_PATH_STYLE, 'js');
        return true;
    }
    
    public function DeleteTMPCache()
    {
        $this->DeleteCache(_CACHE_PATH_TMP, 'tmp');
        return true;
    }

    private function DeleteCache($path, $type = 'css')
    {
    	$gzExtensions = Mozg_Cfg::Get('global')->GetGzExtensions();
    	
        switch ($type)
        {
            case 'html':
                    $exts = array('html', $gzExtensions['html']);
                break;
        	
            case 'css':
                    $exts = array('css', $gzExtensions['css']);
                break;
                
            case 'js':
                    $exts = array('js', $gzExtensions['js']);
                break;

            case 'tmp':
                    $exts = array('phtml', 'js');
                break;
                
            default: throw new Mozg_Exception_System(Mozg_Lang::_('UNKNOWN_FILE_TYPE'));
        }
        
        Mozg::Lib('Dir')->DelFilesByType($path, $exts);
    }
}